/*     */ package com.qmsk.business.task.complaint.controller;
/*     */ 
/*     */ import com.qmsk.business.task.complaint.dao.ComplaintDao;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/complnt"})
/*     */ public class ComplaintController
/*     */ {
/*  36 */   private static final Logger logger = Logger.getLogger(ComplaintController.class);
/*     */ 
/*     */   @Autowired
/*     */   private ComplaintDao dao;
/*     */ 
/*     */   @RequestMapping(value={"find/complaintList/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getList(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */     throws Exception
/*     */   {
/*  66 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  68 */       Map params = new HashMap();
/*     */ 
/*  70 */       MapUtils.addToMap(params, "dtBegin", 
/*  71 */         RequestUtils.getString(request, "dtBegin"));
/*  72 */       String dtEnd = RequestUtils.getString(request, "dtEnd");
/*  73 */       params.put("status", RequestUtils.getString(request, "status"));
/*  74 */       MapUtils.addPercentToMap(params, "cusName", 
/*  75 */         RequestUtils.getString(request, "cusName"));
/*  76 */       GsonEbRst gsonEbRst = this.dao.getGsonOfParams(params, nPageIdx, 
/*  77 */         nPageSize);
/*  78 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  80 */       logger.error(e);
/*  81 */       ResponseUtils.setErrorMsgResponse(
/*  82 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/complaintById/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try
/*     */     {
/*  99 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(id);
/* 100 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 102 */       logger.error(e);
/* 103 */       ResponseUtils.setErrorMsgResponse(
/* 104 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"insert/insertInfo"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insertInfo(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try {
/* 112 */       int nResult = 0;
/* 113 */       String sData = RequestUtils.getStringOfData(request);
/* 114 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 115 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 116 */         GsonHeadOneRow g = (GsonHeadOneRow)p.getListInsertRows().get(0);
/* 117 */         g.addHeadData("submitDate", new Date());
/* 118 */         g.addHeadData("status", Integer.valueOf(0));
/* 119 */         g.addHeadData("billFrom", "WX");
/* 120 */         g.addHeadData("cmpltDate", new Date());
/* 121 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/*     */       else {
/* 124 */         ResponseUtils.setErrorMsgResponse(
/* 125 */           RequestUtils.getReadDataErrorMessage(request), 
/* 126 */           response);
/* 127 */         return;
/*     */       }
/* 129 */       if (nResult > 0)
/* 130 */         this.dao.commit();
/*     */       else {
/* 132 */         this.dao.rollback();
/*     */       }
/* 134 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 135 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 136 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 139 */       logger.error(e);
/* 140 */       ResponseUtils.setErrorMsgResponse(
/* 141 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 142 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 160 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 162 */       String[] strParams = id.split(",");
/* 163 */       int nResult = this.dao.deleteParams(strParams);
/* 164 */       if (nResult > 0)
/* 165 */         DbConnection.commit();
/*     */       else {
/* 167 */         DbConnection.rollback();
/*     */       }
/* 169 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 170 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 171 */         response);
/*     */     } catch (Exception e) {
/* 173 */       DbConnection.rollback();
/* 174 */       logger.error(e);
/* 175 */       ResponseUtils.setErrorMsgResponse(
/* 176 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 177 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.task.complaint.controller.ComplaintController
 * JD-Core Version:    0.5.3
 */